﻿@{
    ViewBag.Title = "login";
    Layout = null;
}

<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="~/res/assets/images/favicon.png">
    <title>周游库存管理平台--登录</title>
    <!-- Bootstrap Core CSS -->
    <link href="~/res/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="~/res/css/style.css" rel="stylesheet">
    <!-- You can change the theme colors from here -->
    <link href="~/res/css/colors/blue.css" id="theme" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" />
        </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <section id="wrapper">
        <div class="login-register" style="background-image:url(../res/assets/images/background/login-register.jpg);">
            <div class="login-box card">
                <div class="card-body">
                    <form class="form-horizontal form-material" id="loginform">
                        <h3 class="box-title m-b-20">Sign In</h3>
                        <div class="form-group ">
                            <div class="col-xs-12">
                                <input id="ACCOUNT" class="form-control" type="text" required="" placeholder="邮箱/手机号">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-xs-12">
                                <input id="PAS" class="form-control" type="password" required="" placeholder="密码" maxlength="10">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-12">
                                <div class="checkbox checkbox-primary pull-left p-t-0">
                                    <input id="checkbox-signup" type="checkbox">
                                    <label for="checkbox-signup"> 记住用户 </label>
                                </div>
                                <a href="javascript:void(0)" id="to-recover" class="text-dark pull-right"><i class="fa fa-lock m-r-5"></i> 忘记密码?</a>
                            </div>
                        </div>
                        <div class="form-group text-center m-t-20">
                            <div class="col-xs-12">
                                <button id="BtLogin" class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light waves-light" type="submit">登录</button>
                            </div>
                        </div>
                        <div class="form-group m-b-0">
                            <div class="col-sm-12 text-center">
                                <p>没有账户? <a href="../Home/register" class="text-info m-l-5"><b>注册</b></a></p>
                                <h4 style="text-align:left"><b style="color:red;">请在PC电脑上浏览系统，体验最佳效果</b></h4>
                            </div>
                        </div>
                    </form>

                    <form class="form-horizontal" id="recoverform">
                        <div class="form-group ">
                            <div class="col-xs-12">
                                <h3>重置密码</h3>
                                <p class="text-muted">输入邮箱，验证信息将会发送到您的邮箱! </p>
                            </div>
                        </div>
                        <div class="form-group ">
                            <div class="col-xs-12">
                                <div class="input-group">

                                    <input type="email" id="InEmail" class="form-control" required="" placeholder="邮箱">
                                    <span class="input-group-btn">
                                        <button id="SendBt" class="btn btn-primary btn-lg btn-block text-uppercase waves-effect waves-light" type="submit">发送验证码</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-xs-12">
                                <input id="InCode" class="form-control" type="text" placeholder="验证码" maxlength="4" style="display:none">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-12">
                                <a href="javascript:void(0)" id="to-recoverLogin" class="text-dark pull-right"><i class="fa fa-user-circle m-r-5"></i> 返回登录</a>
                            </div>
                        </div>
                        <div class="form-group text-center m-t-20">
                            <div class="col-xs-12">
                                <button id="ReBt" class="btn btn-primary btn-lg btn-block text-uppercase  waves-effect waves-light" type="button" style="display:none">确定</button>
                            </div>
                        </div>
                    </form>

                    <form class="form-horizontal" id="rePasform">
                        <div class="form-group ">
                            <div class="col-xs-12">
                                <h3>请输入新密码</h3>
                                <p class="text-muted">密码至少6位! </p>
                            </div>
                        </div>
                        <div class="form-group ">
                            <div class="col-xs-12">
                                <input id="NEWPAS" class="form-control" type="password" required="" placeholder="新密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-xs-12">
                                <input id="NEWPASTWO" class="form-control" type="password" required="" placeholder="确认新密码" maxlength="10">
                            </div>
                        </div>
                        <div class="form-group text-center m-t-20">
                            <div class="col-xs-12">
                                <button id="BtPAS" class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light waves-light" type="submit">重置</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>

    </section>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="~/res/assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="~/res/assets/plugins/bootstrap/js/popper.min.js"></script>
    <script src="~/res/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="~/res/js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="~/res/js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="~/res/js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="~/res/assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <script src="~/res/assets/plugins/sparkline/jquery.sparkline.min.js"></script>
    <!--Custom JavaScript -->
    <script src="~/res/js/custom.js"></script>
    <!-- ============================================================== -->
    <!-- Style switcher -->
    <!-- ============================================================== -->
    <script src="~/res/assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
    <link href="~/res/assets/plugins/sweetalert/sweetalert.css" rel="stylesheet" type="text/css">
    <script src="~/res/assets/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="~/res/js/jquery.cookie.js"></script>
    <script>
        $(function () {
            $("#rePasform").slideUp();
            if ($.cookie('AccountName') != undefined) {
                $("#ACCOUNT").val($.cookie('AccountName'));
                $("#checkbox-signup").prop('checked', true);
            }

            $("#loginform").submit(function (e) {

                $("#BtLogin").html("登录中，请稍后...");
                $("#BtLogin").attr('disabled', true);
                $.post("../Home/login?act=login", {
                    ACCOUNT: $("#ACCOUNT").val(),
                    PAS: $("#PAS").val(),
                    REMEMBER: $("#checkbox-signup").prop('checked')
                },
                    function (data) {
                        data = JSON.parse(data);
                        $("#BtLogin").removeAttr("disabled");
                        if (data.status === 0) {
                            $("#BtLogin").html("登录成功，正在跳转...");
                            window.setTimeout(function () {
                                window.location.href = "../Essential/Enterprise";
                            }, 500);
                        } else {
                            $("#BtLogin").html("登录");
                            swal("登录失败!", data.message);
                            return false;
                        }
                    });
                return false;
            });
            var interval = null;
            var RecoverTime = 60;
            $("#recoverform").submit(function (e) {
                $("#SendBt").html("验证码发送中...");
                $("#SendBt").attr('disabled', true);
                $.post("../Home/login?act=SendCode", { Mail: $("#InEmail").val() },
                    function (data) {
                        data = JSON.parse(data);
                        if (data.status === 0) {
                            $("#SendBt").attr('disabled', true);
                            interval = setInterval(RecoverTimeFu, 1000);
                            $("#InCode").show();
                            $("#ReBt").show();
                        } else {
                            $("#SendBt").html("发送验证码");
                            $("#SendBt").attr('disabled', false);
                            swal("发送失败!", data.message);
                            return false;
                        }
                    });

                return false;
            });
            function RecoverTimeFu() {
                RecoverTime = RecoverTime - 1;
                $("#SendBt").html(RecoverTime);
                if (RecoverTime === 0) {
                    clearInterval(interval);
                    interval = null;
                    $("#SendBt").html("发送验证码");
                    $("#SendBt").attr('disabled', false);
                }
            }

            $("#ReBt").click(function () {
                if ($("#InCode").val() === "") {
                    swal("提示!", "请输入验证码");
                    return false;
                }
                $.post("../Home/login?act=CheckCode", { Mail: $("#InEmail").val(), InCode: $("#InCode").val() },
                    function (data) {
                        data = JSON.parse(data);
                        if (data.status === 0) {
                            $("#recoverform").slideUp();
                            $("#rePasform").fadeIn();
                        } else {
                            swal("操作失败!", data.message);
                            return false;
                        }
                    });
            });

            $("#rePasform").submit(function (e) {
                if ($("#NEWPAS").val() !== $("#NEWPASTWO").val()) {
                    swal("提示!", "两次密码不一致");
                    return false;
                }
                if ($("#NEWPAS").val().length<6) {
                    swal("提示!", "密码长度小于6位");
                    return false;
                }
                $.post("../Home/login?act=rePas", 
                    { Mail: $("#InEmail").val(), InCode: $("#InCode").val(), NEWPAS: $("#NEWPAS").val() },
                    function (data) {
                        data = JSON.parse(data);
                        if (data.status === 0) {
                            swal("重置成功!", "将为您跳转回登录窗口");
                            $("#recoverform")[0].reset();
                            $("#rePasform")[0].reset();

                            $("#rePasform").slideUp();
                            $("#loginform").fadeIn();
                        } else {
                            swal("重置失败!", data.message);
                            return false;
                        }
                    });

                return false;
            });
        });
    </script>

</body>
</html>


